package 曾世昌12_2;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class test {
    public static void main(String[] args) {
        ArrayList<dog> dogs = new ArrayList<>();
        dogs.add( new dog( "哈士奇", 1, 3 ) );
        dogs.add( new dog( "藏獒", 2, 12 ) );
        dogs.add( new dog( "博美", 2, 6 ) );
        dogs.add( new dog( "柴犬", 3, 12 ) );
        System.out.println( dogs );
        Collections.sort( dogs, new Comparator<dog>() {
            @Override
            public int compare(dog o1, dog o2) {
                if (o1.age - o2.age > 0) return -1;
                if (o1.age - o2.age == 0) return o1.weigth > o2.weigth ? -1 : 0;
                return 0;
            }
        } );
        System.out.println( dogs );
    }
}
